/**
 * 属性管理相关的接口函数
 */
// 0. 引入异步对象
import request from '@/utils/request'
import type { categorayIdsModel } from './model/categorySelectorModel'
import type { attrInfoModel } from './model/attrModel'
// 1. 使用枚举来存储接口地址
enum Api {
  getAttrListData='/admin/product/attrInfoList',
  saveAttrListData='/admin/product/saveAttrInfo',
  deleteAttrListData='/admin/product/deleteAttr'
  // /admin/product/saveAttrInfo
  // /admin/product/deleteAttr/{attrId}
}
// 定义接口函数并导出

// 2. 根据一二三级导航ID 来获取属性列表 
export const reqGetAttrListData = ({ category1Id, category2Id, category3Id }:categorayIdsModel) => {
  return request.get<any,attrInfoModel>(`${Api.getAttrListData}/${category1Id}/${category2Id}/${category3Id}`)
}
// 更新属性
export const reqSaveAttrListData = (attrInfo:attrInfoModel)=>{
  return request.post<any,null>(Api.saveAttrListData,attrInfo)
}
// 删除属性
export const reqDeleteAttrListData = (id:number)=>{
  return request.delete<any,null>(Api.deleteAttrListData+`/${id}`)
}